﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using plas.core;
using plas.common.api;
using plas.common.api.domain;
using plas.common.api.tools;
using plas.cps.api.services;


namespace plas.cps.ui
{
    public partial class MainForm : AbstractForm
    {
        public MainForm()
        {
            InitializeComponent();
          
        }

        AbstractForm tf;

        //private ISystemConfiguration configService;

        //public ISystemConfiguration ConfigService
        //{
        //    get { return configService; }
        //    set { configService = value; }
        //}
        private IUserService userService;

        public IUserService UserService
        {
            get { return userService; }
            set { userService = value; }
        }

        public AbstractForm Tf
        {
            get { return tf; }
            set { tf = value; }
        }

        private void MainForm_Load(object sender, EventArgs e)
        {

            //SystemConfigurationEntity configuration = (SystemConfigurationEntity)ApplicationHandler.GetInstance().Cache.GetApplication(ToisSystemHandle.CACHE_TOIS_CONFIGURATION);

            plas.common.api.domain.UserEntity user = (plas.common.api.domain.UserEntity)ApplicationHandler.GetInstance().Cache.GetSession("plas.common.cache.user");

            //showSystemConfig(configuration);

            initButtonStatus();
            bindButtons(tf);
            tf.MdiParent = this;
            //tf.WindowState = FormWindowState.Maximized;
            tf.Show();
            tf.Update();
        }

        /// <summary>
        /// 初始化按钮状态
        /// </summary>
        private void initButtonStatus()
        {
            this.btnNew.Enabled = false;
            this.btnSave.Enabled = false;
            //this.btnSaveAll.Enabled = false;
            this.btnDelete.Enabled = false;
        }
        /// <summary>
        /// 绑定按钮
        /// </summary>
        /// <param name="form"></param>
        private void bindButtons(AbstractForm form)
        {
            form.bindCommand(this.btnNew);
            form.bindCommand(this.btnSave);
            //form.bindCommand(this.btnSaveAll);
            form.bindCommand(this.btnDelete);
            //form.bindCommand(this.btnEnable);
        }

        private Point mPoint = new Point();

        private void MainForm_MouseDown(object sender, MouseEventArgs e)
        {
            mPoint.X = e.X;
            mPoint.Y = e.Y;
        }

        private void MainForm_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                Point myPosittion = MousePosition;
                myPosittion.Offset(-mPoint.X, -mPoint.Y);
                Location = myPosittion;
            }
        }



        private void buttonX1_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Maximized;
        }

        private void DesktopTab_Click(object sender, EventArgs e)
        {
            ApplicationHandler actual = ApplicationHandler.GetInstance();
            Form df = (Form)actual.GetObject("DesktopForm");
            df.MdiParent = this;
            df.Show();
           
        }

        private void CustomerTab_Click(object sender, EventArgs e)
        {
            ApplicationHandler actual = ApplicationHandler.GetInstance();
            Form cf = (Form)actual.GetObject("CustomerForm");
            cf.MdiParent = this;
            cf.Show();

        }

        private void VideoShowTabItem_Click(object sender, EventArgs e)
        {
            ApplicationHandler actual = ApplicationHandler.GetInstance();
            Form vsf = (Form)actual.GetObject("VideoShowForm");
            vsf.MdiParent = this;
            vsf.Show();

        }

        private void ShoppingCartTabItem_Click(object sender, EventArgs e)
        {
            ApplicationHandler actual = ApplicationHandler.GetInstance();
            Form scf = (Form)actual.GetObject("ShoppingCartForm");
            scf.MdiParent = this;
            scf.Show();
        }

        private void OrderTabItem_Click(object sender, EventArgs e)
        {
            ApplicationHandler actual = ApplicationHandler.GetInstance();
            Form of = (Form)actual.GetObject("OrderForm");
            of.MdiParent = this;
            of.Show();
        }

        private void ResManage_Click(object sender, EventArgs e)
        {
            ApplicationHandler actual = ApplicationHandler.GetInstance();
            Form rmf = (Form)actual.GetObject("ResManageForm");
            rmf.MdiParent = this;
            rmf.Show();
        }

        private void PersonResTabItem_Click(object sender, EventArgs e)
        {
            ApplicationHandler actual = ApplicationHandler.GetInstance();
            Form prmf = (Form)actual.GetObject("PersonResManageForm");
            prmf.MdiParent = this;
            prmf.Show();
        }

        private void HotelResTabItem_Click(object sender, EventArgs e)
        {
            ApplicationHandler actual = ApplicationHandler.GetInstance();
            Form hrmf = (Form)actual.GetObject("HotelResManageForm");
            hrmf.MdiParent = this;
            hrmf.Show();
        }

        private void InfoManageTab_Click(object sender, EventArgs e)
        {
            ApplicationHandler actual = ApplicationHandler.GetInstance();
            Form imf = (Form)actual.GetObject("InfoManageForm");
            imf.MdiParent = this;
            imf.Show();
        }

        private void tabItem1_Click(object sender, EventArgs e)
        {
            ApplicationHandler actual = ApplicationHandler.GetInstance();
            Form vsf = (Form)actual.GetObject("InfoManageForm");
            vsf.MdiParent = this;
            vsf.Show();
        }

        private void tabItem2_Click(object sender, EventArgs e)
        {
            ApplicationHandler actual = ApplicationHandler.GetInstance();
            Form omf = (Form)actual.GetObject("OrderManageForm");
            omf.MdiParent = this;
            omf.Show();

        }

        private void tabItem4_Click(object sender, EventArgs e)
        {
            ApplicationHandler actual = ApplicationHandler.GetInstance();
            Form vmf = (Form)actual.GetObject("VideoManageForm");
            vmf.MdiParent = this;
            vmf.Show();
        }

        private void tabItem3_Click(object sender, EventArgs e)
        {
            ApplicationHandler actual = ApplicationHandler.GetInstance();
            Form wmf = (Form)actual.GetObject("WorkManageForm");
            wmf.MdiParent = this;
            wmf.Show();
        }

        private void UserTab_Click(object sender, EventArgs e)
        {
            ApplicationHandler actual = ApplicationHandler.GetInstance();
            Form userf = (Form)actual.GetObject("UserForm");
            userf.MdiParent = this;
            userf.Show();
        }

        private void DictionaryTab_Click(object sender, EventArgs e)
        {
            ApplicationHandler actual = ApplicationHandler.GetInstance();
            Form dicf = (Form)actual.GetObject("DictionaryForm");
            dicf.MdiParent = this;
            dicf.Show();
        }

        private void SetTab_Click(object sender, EventArgs e)
        {
            ApplicationHandler actual = ApplicationHandler.GetInstance();
            Form setf = (Form)actual.GetObject("SettingForm");
            setf.MdiParent = this;
            setf.Show();
        }

      
      

    }
}
